package crazyFace.system.app;

import android.graphics.Bitmap;

public class Entity extends Sprite{
	
	protected float life = 100;
	protected float maxHealth = 100;
	protected int ammo = 250;
	public int ObjectID = 1;
	public float dam;
	public int command = 100;
	public int bulletdam;
	public int multidam;
	public float speed = 1;
	public boolean isRows = true;

	public Entity(GameView gameView, Bitmap bmp, int rows, int columns) {
		super(gameView, bmp, rows, columns);
		
		
	}
	
	public Entity(GameView gameView, Bitmap bmp, int rows, int columns, int life) {
		super(gameView, bmp, rows, columns);
		
		
	}
	
	public void hit(){
		life -= multidam;
	}
	
	public void heal(){
		life += 10;
		if(life > maxHealth){
			life = maxHealth;
		}
	}
	
	public void kill(int index){
		
	}
	
	public void setMaxHealth(float health){
		maxHealth = health;
	}
	
	public void addMaxHealth(float health){
		maxHealth += health;
	}
	
	public boolean checkSelf(){
		if(x > GameView.xBound || (x + dstwidth) < 0 || y > GameView.yBound || (y + dstheight) < 0){
			return true;
		}else if(life < 1){
			 return true;
		}else
			return false;
	}
	
	@Override
	protected void update() {
		super.update();
	}
	
	public int getCenterX(){
		return (int) (x + (dstwidth / 2));
	}
	
	public int getCenterY(){
		return (int) (y + (dstheight / 2));
	}
	
	public void follow(float x, float y){
		float tempX = x - (getCenterX());
		float tempY = y - (getCenterY());
		float distance = (float) Math.sqrt((tempX * tempX) + (tempY * tempY));
		
		xSpeed = (tempX / distance) * speed;
		ySpeed = (tempY / distance) * speed;
		
		this.x += xSpeed;
		this.y += ySpeed;
		if(isRows){
			updateFrameRows();
		}else
			updateFrameSimple();
		
	}
	
	public void move(){
		
	}

}
